﻿using iAgileFramework.DataTransCarrier;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;


namespace WebApplication1
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            RegisterConnection();
        }

        /// <summary>
        /// 说明：注册数据库链接
        /// 作者：林开
        /// 时间：2016-5-11 19:54:40
        /// </summary>
        private static void RegisterConnection()
        {
            #region 数据链接
            var listDbConnections = new List<DbConnectionInfo>();
            var config = ConfigurationManager.ConnectionStrings["DefaultConnection"];
            listDbConnections.Add(
                new DbConnectionInfo(
                    config.Name,
                    () => new SqlConnection(config.ConnectionString),
                    () => SqlClientFactory.Instance));

            #endregion

            ConnectionManager.Register(listDbConnections, null);
        }
    }
}
